
<template>
  <el-table :data="form" style="width: 100%">
    <el-table-column type="expand">
      <template slot-scope="props">
        <el-form label-position="left" inline class="demo-table-expand">
          <el-form-item label="姓名">
            <span>{{ props.row.name }}</span>
          </el-form-item>
          <el-form-item label="用户ID">
            <span>{{ props.row._id }}</span>
          </el-form-item>
          <el-form-item label="审核状态">
            <span v-if="props.row.lessor=='1'" style="color:red">待审核</span>
            <span v-else-if="props.row.lessor=='2'" style="color:green">审核通过</span>
            <span v-else-if="props.row.lessor=='3'" style="color:red">审核失败</span>
          </el-form-item>
        </el-form>
        <el-form inline style="width:100%" label-position="left">
          <el-form-item>
            <el-popconfirm title="确定该用户通过审核吗？" @onConfirm="pass">
              <el-button slot="reference" style="backgroundColor:#5CBB7A">审核通过</el-button>
            </el-popconfirm>
          </el-form-item>
          <el-form-item>
            <el-popconfirm title="确定该用户审核失败吗？" @onConfirm="unpass">
              <el-button slot="reference" style="backgroundColor:#F56C6C">拒绝审核</el-button>
            </el-popconfirm>
          </el-form-item>
        </el-form>
      </template>
    </el-table-column>
    <el-table-column label="姓名" prop="name"></el-table-column>
    <el-table-column label="账号" prop="account"></el-table-column>
    <el-table-column label="身份认证" prop="idcard"></el-table-column>
  </el-table>
</template>
<script>
import axios from "axios";
export default {
  props: ["ownerid"],
  data() {
    return {
      user: {
        _id: "",
        lessor: "2"
      },
      form: []
    };
  },
  mounted() {
    // this.getCar();
    this.getUser();
  },
  methods: {
    // getCar: function() {
    //   axios
    //     .get(`/cars/ownerid`, { params: { ownerid: this.ownerid } })
    //     .then(res => {
    //       this.form[0] = res.data[0];
    //       console.log(this.form);
    //     });
    // }
    unpass: function() {
        this.user.lessor="3";
        console.log("123")
        axios.put("/users/pass", this.user).then(res => {
        if (res.data) {
          alert("修改成功");
        }
        this.getUser();
      });
    },
    pass: function() {
      console.log(this.user);
      axios.put("/users/pass", this.user).then(res => {
        if (res.data) {
          alert("修改成功");
        }
        this.getUser();
      });
    },
    getUser: function() {
      axios
        .get(`/users/getOneUser`, { params: { _id: this.ownerid } })
        .then(res => {
          //   console.log(res.data);
          this.form = res.data;
          this.user._id = res.data[0]._id;
        });
    }
  }
};
</script>

<style>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>